<?php

namespace app\common\model;
use think\Model;
use app\common\model\GoodsComment;
class GoodsReply extends Model
{
	protected $table = 'goods_reply';
	protected $pk = 'reply_id';
	protected $autoWriteTimestamp = true;
	protected $createTime = 'reply_create_time'; 
	protected $updateTime = false;

	public static function insert($data)
	{
		$result = db('goods_reply')->insert($data);
		if($result)
		{
			$r = GoodsComment::where('comment_id', $data['reply_comment_id'])->setField('comment_is_reply', 1);
		}

		return $result;
	}


	protected static function init()
	{
		GoodsReply::beforeInsert(function ($goodsReply) 
		{
			$merchant_id = session('merchant')['merchant_id'];
			$goodsReply['reply_merchant_id'] = $merchant_id;
		});
	}
} 


